<include file="./Application/Home/View/default/public/header.html" title="浏览教员"/>
<link rel="stylesheet" type="text/css" href="/Public/teacherList/resource/teacherList.css">
<div class="container body-margin">
<div class="row">
    <div class="col-md-12 filter-wrapper" style="padding: 0;">
        <div id="filter" style="margin-bottom: 37px;">
            <div class="filter">
                <div class="select-grade clearfix">
                    <span class="heading">选择年级: &nbsp;</span>
                    <div class="course-list">
                        <a href="/Home/Index/teacherList/lesson/<?php echo $filter['lesson']; ?>/sex/<?php echo $filter['sex']; ?>/school/<?php echo $filter['school']; ?>/grade/0" class="btn btn-filter <?php if($filter['grade']==0) echo 'active'; ?>" id="all_grade">不限</a>
                        <?php
                                foreach ($grade as $key => $value) {
                        ?>
                        <a href="/Home/Index/teacherList/lesson/<?php echo $filter['lesson']; ?>/sex/<?php echo $filter['sex']; ?>/school/<?php echo $filter['school']; ?>/grade/<?php echo $key; ?>" class="btn btn-filter <?php if($filter['grade']==$key) echo 'active'; ?>" id="primary"><?php echo $value;?></a>
                        <?php
                                }
                            ?>
                    </div>
                </div>
                <div class="select-subject clearfix" style="margin-top: 15px;">
                    <span class="heading">选择科目: &nbsp;</span>
                    <div class="course-list">
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/sex/<?php echo $filter['sex']; ?>/school/<?php echo $filter['school']; ?>/lesson/0" class="btn btn-filter <?php if($filter['lesson']==0) echo 'active'; ?>">不限</a>
                        <?php
                                foreach ($lesson as $key => $value) {
                        ?>
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/sex/<?php echo $filter['sex']; ?>/school/<?php echo $filter['school']; ?>/lesson/<?php echo $key; ?>" class="btn btn-filter <?php if($filter['lesson']==$key) echo 'active'; ?>"><?php echo $value; ?></a>
                        <?php
                                }
                            ?>
                    </div>
                </div>
                <div class="select-school clearfix" style="margin-top: 15px;">
                    <span class="heading">选择学校: &nbsp;</span>
                    <div class="course-list">
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/sex/<?php echo $filter['sex']; ?>/lesson/<?php echo $filter['lesson']; ?>/school/0" class="btn btn-filter <?php if($filter['school']==0) echo 'active'; ?>">不限</a>
                        <?php
                                foreach ($school as $key => $value) {
                        ?>
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/sex/<?php echo $filter['sex']; ?>/lesson/<?php echo $filter['lesson']; ?>/school/<?php echo $key; ?>" class="btn btn-filter <?php if($filter['school']==$key) echo 'active'; ?>"><?php echo $value; ?></a>
                        <?php
                                }
                            ?>
                    </div>
                </div>
                <div class="select-gender clearfix" style="margin-top: 15px;">
                    <span class="heading">选择性别: &nbsp;</span>
                    <div class="course-list">
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/lesson/<?php echo $filter['lesson']; ?>/school/<?php echo  $filter['school']; ?>/sex/0" class="btn btn-filter <?php if($filter['sex']==0) echo 'active'; ?>">不限</a>
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/lesson/<?php echo $filter['lesson']; ?>/school/<?php echo  $filter['school']; ?>/sex/1" class="btn btn-filter <?php if($filter['sex']==1) echo 'active'; ?>">男</a>
                        <a href="/Home/Index/teacherList/grade/<?php echo $filter['grade']; ?>/lesson/<?php echo $filter['lesson']; ?>/school/<?php echo  $filter['school']; ?>/sex/2" class="btn btn-filter <?php if($filter['sex']==2) echo 'active'; ?>">女</a>
                    </div>
                </div>
            </div>

            <div class="modal fade" id="FastFindModal" tabindex="-1" role="dialog" aria-labelledby="FastFindModalLabel" aria-hidden="true">
                <div class="modal-dialog text-center">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">×</span>
                            </button>
                            <h4 class="modal-title" id="FastFindModalLabel">请填写相关信息</h4>
                        </div>

                        <div class="modal-body">
                            <div class="login-form" ng-controller="FastOrderCtrl">
                                <form>
                                    <div class="row">
                                        <div class="col-md-3 col-xs-12">
                                        </div>
                                        <div class="col-md-12 col-xs-12">
                                            <div class="form-group clearfix">
                                                <label class="control-label left" for="phone">
                                                    姓名
                                                </label>
                                                <input type="name" class="form-control login-field long_name pop-form-control" value="" placeholder="请输入姓名" id="phone" name="name" required="">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group clearfix">
                                        <label class="control-label left" for="subject" style=" line-height: 47px;">年级</label>
                                        <select name="grade" id="grade">
                                            <option value="" selected>请选择年级</option>
                                            <option value="1">一年级</option>
                                            <option value="2">二年级</option>
                                            <option value="3">三年级</option>
                                            <option value="4">四年级</option>
                                            <option value="5">五年级</option>
                                            <option value="6">六年级</option>
                                            <option value="7">七年级</option>
                                            <option value="8">八年级</option>
                                            <option value="9">九年级</option>
                                            <option value="10">高一</option>
                                            <option value="11">高二</option>
                                            <option value="12">高三</option>
                                        </select>
                                    </div>
                                    <div class="form-group clearfix">
                                        <label class="control-label left" for="lesson">科目</label>
                                        <input class="form-control login-field pop-form-control" type="text" placeholder="请输入科目" id="lesson" name="lesson" required="">
                                    </div>
                                    <div class="form-group clearfix">
                                        <label class="control-label left" for="time">时间</label>
                                        <input class="form-control login-field long_time pop-form-control" type="text" placeholder="请输入您预约时间，例：2016-01-01" id="time" name="time" required="">
                                    </div>

                                    <div class="form-group clearfix">
                                        <label class="control-label left" for="location">地址</label>
                                        <input class="form-control login-field  long_address pop-form-control"  type="text" placeholder="请输入您的家庭地址" id="location" name="address" required="">
                                    </div>

                                    <div class="form-group clearfix">
                                        <label class="control-label left" for="desc">备注</label>
                                        <textarea class="form-control login-field  long_remarks pop-form-control" type="text" placeholder="您可以留言备注信息哦" id="desc" name="remarks" rows="3"></textarea>
                                    </div>

                                    <a href="javascript:;" class="btn bg-green white btn-lg btn-block kkk_click  " data-dismiss="modal" type="submit">提交预约</a>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div> <!-- modal ENDS -->
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-3 col-sm-3">
        <div id="teacher_sidebar" class="teacher-sidebar" style="margin-left: -15px;">
            <div class="panel panel-default teacher-sidebar-content">
                <div class="panel-heading">
                    <h3 class="panel-title">人工推荐教员</h3>
                </div>
                <div class="panel-body">
                    <form id="recommend_form">
                        <div class="form-group">
                            <input type="phone" class="form-control advice_phone" placeholder="请输入手机号" name="phone" regx="1\d{10}" required="">
                        </div>
                        <div class="form-group">
                            <textarea class="form-control advice_remarks" type="text"  name="remarks" placeholder="请填写您对教员的要求(辅导科目，性别，成绩，能力，性格等)" rows="4" maxlength="600" required=""></textarea>
                        </div>
                        <a href="javascript:;"  data-login="<?php echo $session_id;?>" class="btn btn-primary btn-lg long_advice" style="float: right;">帮我推荐</a><br /><br />
                        <!-- @test -->
                        <div class="text-center" style="margin-top:15px;">
                            <p>咨询客服 电话：0551-63456053</p>
                        </div>
                    </form>
                </div>
            </div>
            <!-- ./panel -->
        </div>
    </div>
    <div class="col-md-9 col-sm-9 teacher-list">
            <foreach name="data" item="vo" >
                <if condition="$isMobile eq 1 ">
                    <div class="m-teacher-item">
                         <div class="item-head clearfix">
                            <img alt="{$vo.relname} 的头像" src="__ROOT__/upload/{$vo.avatar}" class="portrait">
                            <div class="info-right">
                                <p class="name">{$vo.relname} <i class="icon-desc"></i> <span>培训认证</span></p>
                                <p>学校：{$vo.school}</p>
                                <p>高考成绩：{$vo.score}</p>
                            </div>
                         </div>
                         <div class="item-main">
                             <div class="subject item">
                                 <span>授课科目：</span>
                                 {$vo.lesson}
                             </div>
                             <div class="grade item">
                                 <span>授课年级：</span>
                                 {$vo.grade}
                             </div>
                             <div class="teacher-info">
                                <span>个人描述：</span>
                                <span class="desc">{$vo.description}</p>
                            </div>
                         </div>
                         <div class="item-footer">
                            <?php if(session('type') != 1){?>
                         <if condition="($vo['is_full'] eq 0) ">
                             <a href="javascript:;" class="btn btn-primary long_click" data-id="<?php echo
        $vo['user_id'] ?>">申请预约</a>
                         </if>
                         <if condition="($vo['is_full'] eq 1) ">
                             <a href="javascript:;" class="btn btn-primary is_full" data-id="<?php echo
     $vo['user_id'] ?>">申请预约</a>
                        </if>
                         <?php }?>
                         <a href="/Home/Index/teacherDetail/id/{$vo.user_id}" target="_blank" class="btn btn-primary">查看详情</a>
                         </div>
                    </div>
                <else/>
                    <div class="row teacher-item">
                        <div class="col-md-3 text-center">
                            <img alt="{$vo.relname} 的头像" src="__ROOT__/upload/{$vo.avatar}" class="portrait">
                            <h3 class="name" id="teahcer_name">{$vo.relname}</h3>
                        </div>
                        <div class="col-md-6 left teacher-description">
                            <div class="subject">
                                <span>授课科目：</span>
                                {$vo.lesson}
                            </div>
                            &nbsp;
                            <div class="grade">
                                <span>授课年级：</span>
                                {$vo.grade}
                            </div>
                            <ul>
                                <li>
                                    <p>学校：
                                        {$vo.school}
                                    </p>
                                </li>

                                <li>
                                    <p>高考成绩：{$vo.score}</p>
                                </li>
                                <li>
                                    <p>个人描述：
                                        {$vo.description}
                                    </p>
                                </li>
                            </ul>
                        </div>
                        <div class="col-md-3 right-info">
                            <!-- @todo 加入条件判断 并显示：1 是否认证 2 是否满课 -->
                            <div class="row teacher-status">
                                <div class="col-md-5 training text-center">
                                <img alt="已经培训" height="40" src="__PUBLIC__/index/super_host_50-49a8ac11a8d0ff4f439e8087dcd164cc.png" width="22">
                                <p class="status-desc">培训认证</p>
                                </div>
                                <?php
                                if($vo['is_certified']){
                                ?>
                                <div class="col-md-5 training text-center">
                                    <img alt="科大优师认证" height="40" src="__PUBLIC__/index/star.png" width="40">
                                    <p class="status-desc">科大优师</p>
                                </div>
                                <?php
                                }
                                ?>
                                <?php
                                if($vo['is_full']==1){
                                ?>
                                <div class="col-md-5 training text-center">
                                    <img alt="已满课" height="40" src="__PUBLIC__/index/is_full.jpg" width="40">
                                    <p class="status-desc">已满课</p>
                                </div>
                                <?php
                                }
                                ?>
                            </div>

                            <div class="operation">
                                <?php if(session('type') != 1){?>
                                <if condition="($vo['is_full'] eq 0) ">

                                    <a href="javascript:;" class="btn btn-primary long_click" data-id="<?php echo
    $vo['user_id'] ?>"><i class="iconfont"></i>申请预约</a>
                                </if>
                                <if condition="($vo['is_full'] eq 1) ">
                                    <a href="javascript:;" class="btn btn-primary is_full" data-id="<?php echo
    $vo['user_id'] ?>"><i class="iconfont"></i>申请预约</a>
                                </if>
                                <?php }?>
                                <a href="/Home/Index/teacherDetail/id/{$vo.user_id}" target="_blank" class="btn btn-primary"><i class="iconfont"></i>查看详情</a>
                            </div>
                        </div>
                    </div>
                </if>
            </foreach>
            <div style="display: block">
                <div style="text-align: center">
                    {$render}
                </div>
            </div>
    </div>
</div>
</div>
<include file="./Application/Home/View/default/public/footer.html" />

<script>
    $('.long_advice').click(function(){
        var user_id = 1;
        var phone =  $('.advice_phone').val();
        var remarks =  $('.advice_remarks').val();
        if(!user_id){
            window.location="/Home/Index/login";
        }else if(!phone){
            alert('请填写手机号');
            return false;
        }else{
            $.ajax({
                type:"post",
                url:"/Home/Index/fastparentOrder",
                dataType:"json",
                data:{
                    cellphone:phone,
                    remarks:remarks
                },
                success:function(result){
                    if(result.flag == 1){
                        alert(result.content);
                        location.reload();
                    }else{
                        alert(result.content);
                        location.reload();
                    }
                }
            });
        }
    })


    //
    $('.teacher-list').on('click', '.long_click', function(){
        var id = '<?php echo session('id');?>';
        // 未登录
        if (!id) {
            window.open('/Home/Index/register');
        }
        // 已经登录
        else {
            dataid = $(this).data('id');
            $('#FastFindModal').show().addClass('in');
        }
    });
    $('.teacher-list').on('click', '.is_full', function(){
        var id = '<?php echo session('id');?>';
        // 未登录
        if (!id) {
            window.open('./register');
        }
        // 已经登录
        else {
            alert("该老师已满课");
        }
    });

    // 提交预约
    $('.kkk_click').click(function(){

        var name =  $('.long_name').val();
        var grade =  $('[name=grade]').val();
        var lesson = $('[name=lesson]').val();
        var time =  $('.long_time').val();
        var address =  $('.long_address').val();
        var remarks =  $('.long_remarks').val();
        var coursenum = $('[name=coursenum]').val();
        if (!/^[\u4e00-\u9fa5]{2,4}$/.test(name)){
            alert('请填写学生姓名');
            return false;
        }
        if (grade==""){
            alert('请填写年级和科目');
            return false;
        }
        if (lesson== '') {
            alert('请填写科目');
            return false;
        }
        if( time==""){
            alert('请填写期望时间');
            return false;
        }
        if (coursenum === '') {
            alert('请填写课程时间');
            return false;
        }
        if(!/^[\u4e00-\u9fa5]+$/.test(address)){
            alert('请填写地址');
            return false;
        }
        if( remarks==""){
            alert('请填写备注');
            return false;
        }
        $.ajax({
            type:"post",
            url:"./parentOrder",
            dataType:"json",
            data:{
                teacher_id: dataid,
                grade:grade,
                name:name,
                time:time,
                address:address,
                remarks:remarks,
                lesson: lesson
            },
            success: function(result) {
                if ( result.flag == 1) {
                    alert(result.content);
                    $('#FastFindModal').hide().removeClass('in');
                    location.reload();
                } else{
                    alert(result.content);
                    $('#FastFindModal').hide().removeClass('in');
                    location.reload();
                }
            }
        });
    })
    // 关闭语言浮层
    $('.close').click(function(){
        $('#FastFindModal').hide().removeClass('in');

    });
</script>
</body>
</html>
